package com.pn.mapper;

import com.github.pagehelper.Page;
import com.pn.entity.InStore;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

@Mapper
public interface InstoreMapper {
    //显示入库列表
    Page<InStore> instorePageList(InStore inStore);

    //根据id修改入库单状态为已入库
    @Update("update in_store set is_in = 1 where ins_id = #{inStoreId}")
    int setIsInByid(Integer isStoreId);

    //根据商品id修改商品库存
    @Update("update product set product_invent = product_invent + #{param2} where product_id = #{param1}")
    int setInventById(Integer productId,int invent);

    //统计今日入库数量
    @Select("select sum(in_num) from in_store where create_time >= #{param1} and create_time <= #{param2}")
    Integer todayInStoreNum(LocalDateTime begin, LocalDateTime end);

    //统计每月的入库数量
    @Select("select sum(in_num) from in_store where create_time >= #{param1} and create_time <= #{param2}")
    Integer monthInstoreNum(String begin, String end);
}
